using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Trigger : MonoBehaviour
{
    public bool triggered = false;
    public List<FlashLight> targetLights = new List<FlashLight>();

    private bool _CanTrigger = false;
    // Update is called once per frame
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.name == "Player")
            _CanTrigger = true;
    }
    private void OnTriggerExit2D(Collider2D other)
    {
        if (other.gameObject.name == "Player")
            _CanTrigger = false;
    }
    private void Update()
    {

        if (Input.GetKeyDown(KeyCode.E) && _CanTrigger)
        {
            print("E");
            triggered = !triggered;
            foreach (var l in targetLights)
            {
                if (triggered)
                    l.Enable();
                else
                    l.Disable();
            }

        }



    }

}
